import {getplatformList} from "@/api/api";

export const empConfig = {
    data() {
        return {
            platformList:[],//闸机平台列表
            platformTypeList:[],//闸机类型列表
            platformIdList:[],//闸机类型列id集合
            platform:'',//闸机id
            platformModal:false,//闸机弹框
        }
    },
    methods: {
        //查询以接入闸机平台
        getPlatformTypeList(){
            let params = {
            }
            getplatformList(params).then(res=>{
                if(res.code == 200) {
                    this.platformTypeList = [];
                    let list = res.data.list;
                    list.forEach(v => {
                        let obj = {
                            id:v.platform,
                            name:v.name,
                        }
                        this.platformTypeList.push(obj);
                    })
                } else {
                    this.$Message.warning(res.msg);
                }

            }).catch(error=>{
                console.log(error)
            })
        },
        //添加平台
        setPlatform(){
            if(!this.platform){
                this.$Modal.warning({
                    title: "提示",
                    content: "请选择闸机平台"
                });
                return;
            }
            let obj = {
                platform : this.platform,
                appId : '',
                appKey : '',
                appSecret : '',
                remark : '',
            }
            this.platformIdList.push(this.platform);
            this.platformList.push(obj)
            this.platformModal = false;
        },
        //添加平台
        delPlatform(index,list){
            list.splice(index,1);
            this.platformList = list;
            this.platformIdList.splice(index,1);
        },
    },
}
